/**
    [Filename]
    Purpose: [Purpose]

    @author Jason Wojcik
    @version [version]
*/


#include "CApp.h"

void CApp::OnRender(){

    //fill the surface with black background
    SDL_FillRect(Surf_Display, &Surf_Display->clip_rect,
        SDL_MapRGB(Surf_Display->format, 0, 0, 0));



    //render all entities
    for(int i = 0;i < CEntity::EntityList.size();i++) {
        if(!CEntity::EntityList[i]) continue;

        CEntity::EntityList[i]->OnRender(Surf_Display);
    }

    //render the area
   if(!wonGame){
        CArea::AreaControl.OnRender(Surf_Display, -CCamera::CameraControl.GetX(),
        -CCamera::CameraControl.GetY());
   }

    //render the text

    //clear & update the string
    //testString.str(std::string());
    //testString << "This is my text!";

    //add the text into the font surface
    fontSurface = TTF_RenderText_Solid(font, testString.str().c_str(), fontColor);

    //create a rect and set x,y coordinate
    SDL_Rect fontRect;
    fontRect.x = 20;
    fontRect.y = 450;

    //render the text
    SDL_BlitSurface(fontSurface, NULL, Surf_Display, &fontRect);

    //flip the screen
    SDL_Flip(Surf_Display);
}
